package com.seadragon.app.dms.model;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "PURCHASE_ORDER")
public class Order implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 5515335285847993898L;

	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = IDENTITY)
	private long id;

	@OneToOne
	@JoinColumn(name = "CUSTOMER_ID")
	private Customer customer;

	@OneToOne(cascade = CascadeType.PERSIST)
	@JoinColumn(name = "SENDER_ID")
	private Sender sender;

	@OneToOne(cascade = CascadeType.PERSIST)
	@JoinColumn(name = "RECIPIENT_ID")
	private Recipient recipient;

	@OneToMany(mappedBy = "order", cascade = CascadeType.PERSIST)
	private Set<OrderStatus> statuses;

	@Column(name="SERVICE_TYPE")
	private int serviceType;
	
	@Column(name = "PRICE")
	private float price;

	@OneToOne(cascade = CascadeType.PERSIST)
	@JoinColumn(name = "DELIVEREE_ID")
	private Deliveree deliveree;

	@OneToMany(mappedBy="order", cascade = CascadeType.PERSIST, orphanRemoval = true)
	private Set<ShippingPackage> packages;

	@Column(name = "SHIPPING_DATE")
	private Date shippingDate;

	@OneToMany(mappedBy = "order", cascade = CascadeType.PERSIST)
	private Set<Payment> payments;

	@OneToMany(mappedBy = "order", cascade = CascadeType.PERSIST)
	private Set<ScheduledPickupDate> schedulePickupDateList;
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Set<OrderStatus> getStatuses() {
		return statuses;
	}

	public void setStatuses(Set<OrderStatus> statuses) {
		this.statuses = statuses;
	}

	public float getPrice() {
		return price;
	}

	public void setPrice(float price) {
		this.price = price;
	}

	public Sender getSender() {
		return sender;
	}

	public void setSender(Sender sender) {
		this.sender = sender;
	}

	public Recipient getRecipient() {
		return recipient;
	}

	public void setRecipient(Recipient recipient) {
		this.recipient = recipient;
	}

	public Deliveree getDeliveree() {
		return deliveree;
	}

	public void setDeliveree(Deliveree deliveree) {
		this.deliveree = deliveree;
	}

	public Set<ShippingPackage> getPackages() {
		return packages;
	}

	public void setPackages(Set<ShippingPackage> packages) {
		this.packages = packages;
	}

	public Date getShippingDate() {
		return shippingDate;
	}

	public void setShippingDate(Date shippingDate) {
		this.shippingDate = shippingDate;
	}

	public Set<Payment> getPayments() {
		return payments;
	}

	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}

	public Set<ScheduledPickupDate> getSchedulePickupDateList() {
		return schedulePickupDateList;
	}

	public void setSchedulePickupDateList(
			Set<ScheduledPickupDate> schedulePickupDateList) {
		this.schedulePickupDateList = schedulePickupDateList;
	}

	public void setStatusList(Set<OrderStatus> statusList) {
		this.statuses = statusList;
	}

	public int getServiceType() {
		return serviceType;
	}

	public void setServiceType(int serviceType) {
		this.serviceType = serviceType;
	}

}
